##title=finds the first component with the specified Zope if, or all if getAll is set
##parameters=id, getAll=False, meta_type=None

if not id:
    return None

#catalog = context.portal_catalog
catalog = context.knowledgeengine_genericobjectcatalogservice

#query = dict(getId=id)
query = dict(id=id)
if meta_type:
    query['meta_type'] = meta_type

rs = catalog(query)

if getAll:
    return [brain.getObject() for brain in rs]

for brain in rs:
    return brain.getObject()